package borge.web.teamspirit.client.widgets;

import java.util.List;

import borge.web.teamspirit.client.TeamSpirit;
import borge.web.teamspirit.client.TeamSpiritConstants;
import borge.web.teamspirit.client.data.Team;
import borge.web.teamspirit.client.interfaces.WidgetEventHandler;

public class ListTeamsWidget extends ListDataWidget<Team> {

	private String iTitle;
	
	// Either title as string, or take Association/LeagueDivision..but we might
	// want to list teams in many different ways..so ..might be best with string and handle
	// context outside of this widget
	public ListTeamsWidget(WidgetEventHandler aEventHandler, String aTitle, List<Team> aTeams){

		super(aEventHandler, aTeams);
		iTitle = aTitle;
		// populate table with series information
		createDataTable();
		
		initWidget(iPanel);
		
	}
	
	@Override
	protected void createDataTable() {
		// TODO Auto-generated method stub
		
		reset();
		
        TeamSpiritConstants lcs = TeamSpirit.getConstants();
        int row = 0;
        int col = 0;
        
        if(iTitle != null)
        	iTable.setText(row++, col, iTitle);
        
        for(Team team : iData){
        	
        	iTable.setText(row++, col, team.getName());
        	
        }
        
        iPanel.add(iTable);
		
	}


}
